package excel.res;

import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

@ApiModel("导入excel结果")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ImportRes implements Serializable {

    private static final long serialVersionUID = 1L;

    private Integer successCount = 0;

    private Integer failCount = 0;

    private List<List<String>> errDetails = new ArrayList<>();

    public void addSuccessCount() {
        if (Objects.nonNull(successCount)) {
            successCount++;
        }
    }

    public void addSuccessCount(Integer sucNum) {
        if (Objects.nonNull(successCount) && sucNum > 0) {
            successCount += sucNum;
        }
    }

    public void addFailCount() {
        if (Objects.nonNull(failCount)) {
            failCount++;
        }
    }

    public void addFailCount(Integer failNum) {
        if (Objects.nonNull(failCount) && failNum > 0) {
            failCount += failNum;
        }
    }

    public void addErrDetails(List<String> detail) {
        errDetails.add(detail);
    }
}
